package com.hh.game.service.hall.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.hh.game.common.base.exception.GameException;
import com.hh.game.service.hall.domain.User;
import com.hh.game.service.hall.service.LoginService;
import org.apache.dubbo.config.annotation.DubboService;

import java.util.UUID;

@DubboService(delay = -1)
public class LoginServiceImpl implements LoginService {
    @Override
    public JSONObject login(int userId) {
        JSONObject obj = new JSONObject();
        obj.put("code" ,200);
        obj.put("userId" ,userId);
        obj.put("name" ,"name:[" + userId + "]");
        return obj;
    }

    @Override
    public String getAccountId(String code) {
        return code + "@" +UUID.randomUUID().toString();
    }

    @Override
    public JSONObject json(JSONObject json) {
        System.out.println("json :" + json);
        return json;
    }

    @Override
    public void checkThrow(User u1, User u2) {
        throw new GameException(GameException.REQUEST_REPEAT , String.format("u1 [%s] != u2 [%s]" , u1 ,u2));
    }

    @Override
    public byte[] bytes(byte[] bytes) {
        if(bytes != null) {
            System.out.println(new String(bytes));
        }else {
            System.out.println("bytes null---------");
        }
        return bytes;
    }

    @Override
    public String str(String str) {
        System.out.println("---------------------" + str + "------------------------");
        return str;
    }
}
